package com.example.shaoying.yuejian.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;


import com.example.shaoying.yuejian.R;
import com.example.shaoying.yuejian.javabean.ClubVideo;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on 2017/10/3 0003.
 */

public class ClubVideoAdapter extends RecyclerView.Adapter {


    private List videoList;
    private LayoutInflater layoutInflater;
    private Context context;

    public ClubVideoAdapter(Context context, List courseList){
        this.context=context;
        this.videoList=courseList;
    }



    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        View itemView=LayoutInflater.from(context).inflate(R.layout.item_clubvideo,viewGroup,false);
        ClubCourseViewHolder holder=new ClubCourseViewHolder(itemView);
        return holder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {

        ClubCourseViewHolder clubCourseViewHolder= (ClubCourseViewHolder) viewHolder;
        ClubVideo.ClubvideoEntity entity= (ClubVideo.ClubvideoEntity) videoList.get(position);
        final String address="http://172.24.10.175/workout/Uploads/"+entity.getThumb();
        if (!entity.getThumb().equals("")){
            Picasso.with(context).load(address).into(clubCourseViewHolder.videopic);
        }
    }

    @Override
    public int getItemCount() {
        return videoList.size();
    }

    public class ClubCourseViewHolder extends RecyclerView.ViewHolder {

        public ImageView videopic;
        public View itemView;

        public ClubCourseViewHolder(View itemView) {
            super(itemView);
            this.itemView=itemView;
            videopic=(ImageView) itemView.findViewById(R.id.club_info_videopic);
        }
    }
}
